# summary of each competency
p_competency_summary <-
competency_long_fmt_dta |>
count(factor, rating) |>
na.omit() |>
group_by(factor) |>
mutate(
percent = n / sum(n) * 100
) |>
ungroup() |>
mutate(rating = factor(rating, levels = c(1, 2, 3, 4, 5)),
rating = fct_rev(rating)) |>
ggplot(aes(percent, factor, fill = factor(rating))) +
geom_col(size = 1, width = 0.8) +
geom_text(
aes(label = round(percent, 0), x = percent, y = factor),
position = position_stack(vjust = 0.5),
color = "white") +
# scale_fill_manual(values = c("#500207", "#9f040e", "#e30613", "#fa4c58", "#fc9ca2"),
# labels = c("Always", "Usually", "Sometimes", "Rarely", "Never")) +
scale_fill_manual(values = c("#2f3e46", "#3a5a40", "#588157", "#a3b18a", "#dad7cd"),
labels = c("Always", "Usually", "Sometimes", "Rarely", "Never")) +
theme_minimal() +
theme(plot.margin = margin(rep(20, 4)),
plot.title = element_text(hjust = 0.5, size = 14, color = "gray20",
face = "bold", margin = margin(b = 20)),
plot.title.position = "plot",
panel.grid = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(margin = margin(t=10), size = 14),
axis.text = element_text(size = 12, color = "grey20"),
strip.text = element_text(size = 12, face = "bold"),
strip.clip = "off",
legend.position = "right",
legend.text = element_text(size = 12)) +
labs(fill = element_blank(),
x = "Proportion")
## save plot
ggsave("plot/competency_summary.jpeg", width = 10, height = 6, dpi = 300)
## display plot
knitr::include_graphics("plot/competency_summary.jpeg")